package zjut.cocouml.editpolicy;

import java.util.Map;

import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.AbstractEditPolicy;

import zjut.cocouml.command.BInterfaceModifyCommand;
import zjut.cocouml.model.BInterface;

public class ModifyInterfacePolicy extends AbstractEditPolicy {

	public Command getCommand(Request request) {
		if (request.getType().equals("modifyInterface")) {
			return createModifyInterfaceCommand(request);
		}
		return null;
	}
	
	protected Command createModifyInterfaceCommand(Request request) {
		BInterfaceModifyCommand command = new BInterfaceModifyCommand();
		command.setModel((BInterface)getHost().getModel());
		
		System.out.println("ModifyClassPolicy...createModifyClassCommand");
		Map map = request.getExtendedData();
		command.setNewInterfaceName((String)map.get("newName"));
		command.setNewModifiers((String)map.get("modifiers"));

		return command;
	}
}
